package com.youyun56.gps.android;

import android.os.Bundle;
import android.os.Handler;
import android.widget.TextView;

import com.youyun56.gps.android.common.BaseActovity;
import com.youyun56.gps.android.pojo.Car;
import com.youyun56.gps.android.pojo.CarryStatus;
import com.youyun56.gps.android.service.LocationUploadService;

public class UserInfoActivity extends BaseActovity {
    public static Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.userinfo);
        handler = new CarInfoHandler(this);
        Car car = LocationUploadService.getInstance().getCar();
        TextView carId = (TextView) findViewById(R.id.carId);
        TextView carryStatus = (TextView) findViewById(R.id.carryStatus);
        TextView position = (TextView) findViewById(R.id.position);
        TextView lastPositionTime = (TextView) findViewById(R.id.lastPositionTime);
        if (car != null) {
            carId.setText(car.getCarId());
            changeCarryStatus(car.getCarryStatus(), carryStatus);
            position.setText(car.getPosition());
            lastPositionTime.setText(car.getLastPositionTime());
        }
    }

    public void changeCarryStatus(String status, TextView carryStatus) {
        if (status.equals(CarryStatus.GOOD.name())) {
            carryStatus.setText("载重");
        } else if (status.equals(CarryStatus.EMPTY.name())) {
            carryStatus.setText("空车");
        } else {
            carryStatus.setText("未知");
        }
    }
}
